const nodemailer = require("nodemailer");
const fs = require("fs");

const transporter = nodemailer.createTransport({
    host: "smtp.qq.com",
    port: 587,
    secure: false,
    auth: {
        user: '1677214021@qq.com',
        // QQ邮箱开启服务后生成授权码即可
        pass: 'rdwftldzcxukdefj'
    },
});

async function main() {
  const info = await transporter.sendMail({
    from: '"huan" <1677214021@qq.com>',
    to: "987997219@qq.com",
    subject: "hello, email test", 
    // 发送普通文本
    // text: "email test",

    // 发送HTML页面(不支持JS, 但可包含任何HTML+CSS)
    html: fs.readFileSync('./assets/html/index.html')
  });

  console.log("邮件发送成功：", info.messageId);
}

main().catch(console.error);
